package cn.jbt.common.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexpUtil {

    /**
     * <h2>密码中必须包含字母、数字、特殊字符，至少8个字符，最多16个字符</h2>
     */
    public static boolean isPassword(String password) {
        Pattern pattern = Pattern.compile("^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9])(.{8,16})$");
        Matcher matcher = pattern.matcher(password);
        return matcher.matches();
    }

    /**
     * <h2>密码中必须包含字母、数字、特殊字符，至少8个字符，最多16个字符</h2>
     */
    public static boolean isNotPassword(String password) {
        Pattern pattern = Pattern.compile("^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9])(.{8,16})$");
        Matcher matcher = pattern.matcher(password);
        return !matcher.matches();
    }

    /**
     * <h2>手机格式</h2>
     */
    public static boolean isMobile(String mobile) {
        Pattern pattern = Pattern.compile("^1[3456789][0-9]{9}$");
        Matcher matcher = pattern.matcher(mobile);
        return matcher.matches();
    }

    /**
     * <h2>手机格式</h2>
     */
    public static boolean isNotMobile(String mobile) {
        Pattern pattern = Pattern.compile("^1[3456789][0-9]{9}$");
        Matcher matcher = pattern.matcher(mobile);
        return !matcher.matches();
    }

}
